﻿using RestApp.UI.Core;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;

namespace RestApp.UI.Controllers
{
    public class PaymentsApiController : ApiController
    {
        public HttpResponseMessage Get(int idGraphic)
        {
            IBusinessFactory _factory = new RestApp.UI.Core.BusinessLogic();
            var fact = _factory.JobFactsLogic.GetByGraphicId(idGraphic);
            if(fact == null)
            {
                return Request.CreateResponse(HttpStatusCode.NotFound);
            }
            var responseEntity = new
            {
                MustPay = fact.Payment.MustBePay,    
                FactPay = fact.Payment.FactPay,
                Penalties = fact.Payment.Penalties,
                Comment = fact.Payment.Comment
            };

            return Request.CreateResponse(HttpStatusCode.OK, responseEntity);
        }
    }
}
